<extend name="Public/base" />
<block name="style">
<style type="text/css">
[v-cloak] {
  display: none;
}
</style>
</block>
<block name="script">
<script src="__STATIC__/layui/layui.js"></script>
<script>
layui.use(['layer','form'], function(){
    var layer = layui.layer;
    var form = layui.form();
    form.verify({
        template_name:function(value, item){
            if(/^\d+\d+\d$/.test(value)){
                return '模板名称不能全为数字';
            }
        },
        ad_type:function(value, item){
            if(value == -1){
              return '请选择模板类型';
            }
        },
        template_content:function(value, item){
            if(/^\d+\d+\d$/.test(value)){
                return '模板内容不能全为数字';
            }
        }
    });
}); 
</script>
</block>
<block name="body">
    <div class="main-title">
        <if condition="$istype === 'add' ">
            <h2>新增模版</h2>
        <else />
            <h2>修改模版</h2>
        </if>
    </div>
    <if condition="$istype === 'add' ">
        <form id="form" action="{:U('add')}" method="post" class="form-horizontal layui-form">
    <else />
        <form id="form" action="{:U('edit')}" method="post" class="form-horizontal layui-form">
        <input type="hidden" name="id" value="{$data.id}">
    </if>
        <div id="tab1" class="tab-pane in tab1">
            <div class="form-item cf">
                <label class="item-label">模板名称：</label>
                <div class="controls">
                    <input lay-verify="required|template_name" <if condition="$istype === 'edit'">value="{$data.template_name}"</if> type="text" placeholder="请输入标题" class="text input-large" name="template_name">
                </div>
            </div>
            <div class="form-item cf">
                <label class="item-label">模板类型：</label>
                <div class="controls">
                    <select lay-verify="required|ad_type" name="ad_type" lay-ignore>
                        <option value="-1">---请选择---</option>
                        <volist name="types" id="item">
                            <if condition="$istype === 'edit'">
                                <if condition="$item == $data['ad_type']">
                                    <option selected value="{$item}">{$item}</option>
                                <else />
                                    <option value="{$item}">{$item}</option>
                                </if>
                            <else />
                                <option value="{$item}">{$item}</option>
                            </if>
                        </volist>
                    </select>
                </div>
            </div>
            <div class="form-item cf">
                <label class="item-label">模板内容：</label>
                <div class="controls">
                    <label class="textarea input-large">
                        <textarea lay-verify="required|template_content" name="template_content"><if condition="$istype === 'edit'">{$data.template_content}</if></textarea>
                    </label>
                </div>
            </div>
            <div class="form-item cf">
                <button lay-submit class="btn submit-btn">确 定</button>
                <button class="btn btn-return" type="reset">重置</button>
            </div>
        </div>
    </form>
</block>